class Solution
{
public:
    string makeFancyString(string s)
    {
        stringstream ss;
        ss << s[0];
        int repeatCount = 1;
        int n = s.size();
        for (int i = 1; i < n; ++i)
        {
            if (s[i] == s[i - 1])
            {
                ++repeatCount;
            }
            else
            {
                repeatCount = 1;
            }
            if (repeatCount <= 2)
            {
                ss << s[i];
            }
        }
        return ss.str();
    }
};